package gretha.Jtables;

import gretha.donnees.PrixDuBoisEntite;
import gretha.modelsDeJTable.PrixDuBoisTableModel;

import javax.swing.table.TableModel;

public class JTablePrixDuBoisModif extends JTablePrixDuBois{

	/**
	 * 
	 */
	private static final long serialVersionUID = -8820666295778956537L;

	public JTablePrixDuBoisModif(TableModel dm) {
		super(dm);
	}
	
	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		boolean editable = false;
		if(columnIndex == 1)
		{
			editable = true;
		}
	    return editable; 
	}
	
	@Override
	public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
	    if(aValue != null){
	        PrixDuBoisEntite pdb = ((PrixDuBoisTableModel)getModel()).getDonnees()[rowIndex];
	        
	        switch(columnIndex){
	            case 1:
	                pdb.setPrix((Double) aValue);
	                pdb.majEnBase();
	                break;
	          
	        }
	    }
	}

}
